package org.corf.processor;

import org.apache.log4j.Logger;
import org.corf.endpoint.collector.Collector;
import org.corf.endpoint.emitter.Emitter;
import org.corf.payload.Payload;

import com.vodafone.mapreduce.MapReduce;

/**
 * Default processor that covers the basic needs: hosts a collector, an emitter and has a name.
 */
public class DefaultProcessor implements CorfProcessor {

    /**
     * Builder for a default processor instance.
     */
    public static class ProcessorBuilder {
        private String name;
        private Collector collector;
        private Emitter emitter;

        public ProcessorBuilder() {
        }

        String getName() {
            return name;
        }

        void setName(String name) {
            this.name = name;
        }

        ProcessorBuilder withName(String name) {
            setName(name);
            return this;
        }

        Collector getCollector() {
            return collector;
        }

        void setCollector(Collector collector) {
            this.collector = collector;
        }

        ProcessorBuilder withCollector(Collector collector) {
            setCollector(collector);
            return this;
        }

        Emitter getEmitter() {
            return emitter;
        }

        void setEmitter(Emitter emitter) {
            this.emitter = emitter;
        }

        ProcessorBuilder withEmitter(Emitter emitter) {
            setEmitter(emitter);
            return this;
        }

        DefaultProcessor build() {
            DefaultProcessor p = new DefaultProcessor(name, collector, emitter);
            return p;
        }
    }

    public static Logger log = MapReduce.LOG;

    private final String name;
    private final Collector collector;
    private final Emitter emitter;

    protected DefaultProcessor(String name, Collector collector, Emitter emitter) {
        this.name = name;
        this.collector = collector;
        this.emitter = emitter;
    }

    public String toString() {
        return "CorfProcessor: " + name + "::" + collector + "::" + emitter;
    }

    @Override
    public void process(Payload p) {
        // TODO Auto-generated method stub

    }

    @Override
    public void commit(Payload p) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void rollback(Payload p) {
        // TODO Auto-generated method stub
        
    }

}
